package insight;

import java.util.function.Consumer;

/**
 * @author huu
 * @create 2025-08-25-11:17
 */
public class User implements EventListener{

    private String name;
    public User(String name, Consumer<String> consumer) {
        this.name = name;
        this.consumer = consumer;
    }

    //消费者函数----头一次见到
    private final Consumer<String> consumer;
    //目前只能消费着这个天气信息，不能进行其他操作，一直添加其它事件显然不合理，如果有组织来消费
    public void reciveinfo(String info) {
        consumer.accept(info);
    }

    @Override
    public void onEvent(Event event) {
        if(event instanceof WeatherUpdateEvent){
            reciveinfo(event.source().toString());
        }
    }
}
